//===============================================================================
// Microsoft patterns & practices Enterprise Library Contribution
// Common Core Extensions
//===============================================================================

using System;

namespace EntLibContrib.Common
{
	/// <summary>
	/// This interface defines the contract that a class must implement to read
	/// both non-null and nullable data. Use this interface polymorphically rather
	/// than the direct implementations, that way it does not matter how data is read
	/// you can use a single nullable reader method to deal with null values.
	/// </summary>
	/// <remarks>
	/// This modified version of the code project article by Steve Michelotti, makes use of
	/// the <see langword="default"/> keyword for generic types rather than returning null values.
	/// Original article webLink: http://www.codeproject.com/KB/database/NullableReaders.aspx
	/// </remarks>
	public interface INullableReader
	{
		#region Properties
		/// <summary>
		/// The number of columns in the reader;
		/// </summary>
		int FieldCount
		{
			get;
		}
		#endregion

		#region Methods
		/// <summary>
		/// Gets the column name at the ordinal position.
		/// </summary>
		/// <param name="ordinal">The column ordinal.</param>
		/// <returns></returns>
		string GetName(int ordinal);
		/// <summary>
		/// Gets the ordinal position of the column name.
		/// </summary>
		/// <param name="name">The column name.</param>
		/// <returns></returns>
		int GetOrdinal(string name);
		/// <summary>
		/// Gets the boolean value.
		/// </summary>
		/// <param name="name">The column name.</param>
		/// <returns></returns>
		bool GetBoolean(string name);
		/// <summary>
		/// Gets the nullable boolean.
		/// </summary>
		/// <param name="name">The column name.</param>
		/// <returns></returns>
		bool GetNullableBoolean(string name);
		/// <summary>
		/// Gets the byte.
		/// </summary>
		/// <param name="name">The column name.</param>
		/// <returns></returns>
		byte GetByte(string name);
		/// <summary>
		/// Gets the nullable byte.
		/// </summary>
		/// <param name="name">The column name.</param>
		/// <returns></returns>
		byte GetNullableByte(string name);
		/// <summary>
		/// Gets the char.
		/// </summary>
		/// <param name="name">The column name.</param>
		/// <returns></returns>
		char GetChar(string name);
		/// <summary>
		/// Gets the nullable char.
		/// </summary>
		/// <param name="name">The column name.</param>
		/// <returns></returns>
		char GetNullableChar(string name);
		/// <summary>
		/// Gets the date time.
		/// </summary>
		/// <param name="name">The column name.</param>
		/// <returns></returns>
		DateTime GetDateTime(string name);
		/// <summary>
		/// Gets the nullable date time.
		/// </summary>
		/// <param name="name">The column name.</param>
		/// <returns></returns>
		DateTime GetNullableDateTime(string name);
		/// <summary>
		/// Gets the decimal.
		/// </summary>
		/// <param name="name">The column name.</param>
		/// <returns></returns>
		decimal GetDecimal(string name);
		/// <summary>
		/// Gets the nullable decimal.
		/// </summary>
		/// <param name="name">The column name.</param>
		/// <returns></returns>
		decimal GetNullableDecimal(string name);
		/// <summary>
		/// Gets the double.
		/// </summary>
		/// <param name="name">The column name.</param>
		/// <returns></returns>
		double GetDouble(string name);
		/// <summary>
		/// Gets the nullable double.
		/// </summary>
		/// <param name="name">The column name.</param>
		/// <returns></returns>
		double GetNullableDouble(string name);
		/// <summary>
		/// Gets the float.
		/// </summary>
		/// <param name="name">The column name.</param>
		/// <returns></returns>
		float GetFloat(string name);
		/// <summary>
		/// Gets the nullable float.
		/// </summary>
		/// <param name="name">The column name.</param>
		/// <returns></returns>
		float GetNullableFloat(string name);
		/// <summary>
		/// Gets the Guid.
		/// </summary>
		/// <param name="name">The column name.</param>
		/// <returns></returns>
		Guid GetGuid(string name);
		/// <summary>
		/// Gets the nullable Guid.
		/// </summary>
		/// <param name="name">The column name.</param>
		/// <returns></returns>
		Guid GetNullableGuid(string name);
		/// <summary>
		/// Gets the short integer.
		/// </summary>
		/// <param name="name">The column name.</param>
		/// <returns></returns>
		short GetInt16(string name);
		/// <summary>
		/// Gets the nullable short integer.
		/// </summary>
		/// <param name="name">The column name.</param>
		/// <returns></returns>
		short GetNullableInt16(string name);
		/// <summary>
		/// Gets the integer.
		/// </summary>
		/// <param name="name">The column name.</param>
		/// <returns></returns>
		int GetInt32(string name);
		/// <summary>
		/// Gets the nullable integer.
		/// </summary>
		/// <param name="name">The column name.</param>
		/// <returns></returns>
		int GetNullableInt32(string name);
		/// <summary>
		/// Gets the long integer.
		/// </summary>
		/// <param name="name">The column name.</param>
		/// <returns></returns>
		long GetInt64(string name);
		/// <summary>
		/// Gets the nullable long integer.
		/// </summary>
		/// <param name="name">The column name.</param>
		/// <returns></returns>
		long GetNullableInt64(string name);
		/// <summary>
		/// Gets the string.
		/// </summary>
		/// <param name="name">The column name.</param>
		/// <returns></returns>
		string GetString(string name);
		/// <summary>
		/// Gets the nullable string.
		/// </summary>
		/// <param name="name">The column name.</param>
		/// <returns></returns>
		string GetNullableString(string name);
		/// <summary>
		/// Gets the time span.
		/// </summary>
		/// <param name="name">The column name.</param>
		/// <returns></returns>
		TimeSpan GetTimeSpan(string name);
		/// <summary>
		/// Gets the nullable time span.
		/// </summary>
		/// <param name="name">The column name.</param>
		/// <returns></returns>
		TimeSpan GetNullableTimeSpan(string name);
		/// <summary>
		/// Gets a data value with conversion to the given type.
		/// </summary>
		/// <param name="name">The column name.</param>
		/// <param name="type">The data type.</param>
		/// <returns></returns>
		object GetValue(string name, Type type);
		/// <summary>
		/// Gets a data value with conversion to the given type.
		/// </summary>
		/// <param name="name">The column name.</param>
		/// <param name="type">The data type.</param>
		/// <returns></returns>
		object GetNullableValue(string name, Type type);
		/// <summary>
		/// Gets the type information for the column.
		/// </summary>
		/// <param name="name">The column name.</param>
		/// <returns></returns>
		Type GetFieldType(string name);
		/// <summary>
		/// Determines whether the specified name is valid field.
		/// </summary>
		/// <param name="name">The column name.</param>
		/// <returns>
		/// 	<c>true</c> if the specified name is a field; otherwise, <c>false</c>.
		/// </returns>
		bool IsField(string name);
		/// <summary>
		/// Determines whether the value of the named column is equal to DBNull.
		/// </summary>
		/// <param name="name">The column name.</param>
		/// <returns>
		/// 	<c>true</c> if DBNull; otherwise <c>false</c>.
		/// </returns>
		bool IsDBNull(string name);
		#endregion
	}
}
